package main

import (
	"bs/sql"
	"bs/logger"
	"bs/router"
	"fmt"
)

func main() {
	// 开发环境使用 logger.InitLogger("development")
	logger.InitLogger("production")
	defer logger.Sync()

	// 连接数据库
	db, err := sql.NewDB()
	if err != nil {
		logger.Logger.Error("Failed to connect to the database:", err)
		return
	}
	// 初始化路由并启动服务
	r := router.SetupRouter(db)
	if err := r.Run(":8080"); err != nil {
		fmt.Errorf("Failed to start server: %v", err)
	}
}
